
function [accu]=PAA_Query_0606(dist_matrix,k)

%ground truch for ECG

G{1}=[1:18];G{2}=[19:40];G{3}=[41:60];

% dist_matrix=PAA('ECG128_16.mat');

num_ts=size(dist_matrix,1);

for i=1:num_ts
    
    for whichcluster=1:length(G)
        if ismember(i,G{whichcluster})==1
            belongto=G{whichcluster};
            break;
        end
    end
    
   [valuesorted indexsorted]=sort(dist_matrix(i,:));
   closest_k_matches=indexsorted(1:k);
   
   accuracy(i)=length(intersect(closest_k_matches,belongto))/k;
   
end

accu=mean(accuracy)
